<%-- pwd-success.jsp --%>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <title>用户插入成功</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            height: 100vh;
            margin: 0;
            background-color: #f0f2f5;
        }
        .success-box {
            background: white;
            padding: 2rem;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            text-align: center;
        }
        h2 {
            color: #4CAF50;
            margin-bottom: 1.5rem;
        }
        #countdown {
            color: #2196F3;
            font-weight: bold;
            font-size: 1.2em;
        }
    </style>
</head>
<body>
<div class="success-box">
    <h2>✅ 用户插入成功！</h2>
    <p>系统将在 <span id="countdown">3</span> 秒后自动跳转到添加页面</p>
    <p>如果未自动跳转，请<a href="${pageContext.request.contextPath}/jsp/useradd.jsp">点击此处</a></p>
</div>

<script>
    // 倒计时功能
    let seconds = 3;
    const countdownElement = document.getElementById('countdown');

    function updateCountdown() {
        seconds--;
        countdownElement.textContent = seconds;// 将countdownElement元素的文本内容设置为当前的seconds值，这样用户就可以看到倒计时的秒数在变化。

        if (seconds <= 0) {
            window.location.href = "${pageContext.request.contextPath}/jsp/useradd.jsp";
        } else {
            setTimeout(updateCountdown, 1000);// 递归调用，代表1000ms调用一次 updateCountdown
        }
    }

    // 页面加载后启动倒计时
    window.onload = function() {
        setTimeout(updateCountdown, 1000);// 首次调用updateCountdown函数
    };
</script>
</body>
</html>